# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Andreas 'Segaja' Schleifer <segaja at archlinux dot org>
# Maintainer: Daurnimator <daurnimator@archlinux.org>
# Contributor: Eli Schwartz <eschwartz@archlinux.org>
# Contributor: lp76 <l.peduto@gmail.com>
# Contributor: Daenyth <Daenyth+Arch AT gmail DOT com>
# Contributor: Gaetan Bisson <bisson@archlinux.org>

pkgname='ncdu'
pkgver=2.3
pkgrel=1
pkgdesc='Disk usage analyzer with an ncurses interface'
url='https://dev.yorhel.nl/ncdu'
license=('MIT')
depends=('ncurses')
makedepends=('zig')
arch=('loong64' 'x86_64')
source=("https://dev.yorhel.nl/download/${pkgname}-${pkgver}.tar.gz"{,.asc})
sha256sums=('bbce1d1c70f1247671be4ea2135d8c52cd29a708af5ed62cecda7dc6a8000a3c'
            'SKIP')
b2sums=('9fd73fba83c57195f8ffbad5b954140a776d1cd1d7b3e458f832255ee9c07eb8af9888a23ed3c671f508d6ba3795e2361f79e64b4b24630d744470efc5bfaded'
        'SKIP')
validpgpkeys=('74460D32B80810EBA9AFA2E962394C698C2739FA') # Yoran Heling <projects@yorhel.nl>

build() {
    cd "${pkgname}-${pkgver}"

    DESTDIR="build" zig build \
      --prefix /usr \
      --search-prefix /usr \
      -Dtarget=native-linux.5.15-gnu \
      -Dcpu=baseline \
      -Doptimize=ReleaseSafe \
      -Dpie=true
}

check() {
    cd "${pkgname}-${pkgver}"

    zig build test \
      --prefix /usr \
      --search-prefix /usr \
      -Dtarget=native-linux.5.15-gnu \
      -Dcpu=baseline \
      -Doptimize=ReleaseSafe \
      -Dpie=true
}

package() {
    cd "${pkgname}-${pkgver}"

    cp -a build/* "$pkgdir"

    make install-doc PREFIX="${pkgdir}/usr"

    install --verbose -D --mode=644 LICENSES/MIT.txt "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
